from presenter import basepresenter
from domain import comment

class NewsletterPresenter(basepresenter.BasePresenter):

    def respondToGet(self):
        # set up the page title
        page_title = self.sitetitle + ' - Newsletter'
        self.template_values['page_title'] = page_title
        #get the view to draw the page
        self.view.showGetResponse(self.template_values)


    def respondToPost(self):
        if (self.request.get('action') == "Subscribe"):
            self.currentuserprofile.subscriber = True 
            self.userprofiletask.save(self.currentuserprofile)

        if (self.request.get('action') == "Unsubscribe"):
            self.currentuserprofile.subscriber = False
            self.userprofiletask.save(self.currentuserprofile)

        self.generateLoginUrl()
        self.view.showGetResponse(self.template_values)